25. Exercise: Schedule with FirebaseJobDispatcher
Attention Students: WorkManager is now the preferred way to schedule jobs for Android apps. You can learn more about how to use WorkManager in our course Developing Android Apps with Kotlin.
Exercise: Schedule With FirebaseJobDispatcher
Schedule with FirebaseJobDispatcher
This is the second part of a two part exercise. In this exercise you will schedule the WaterReminderFirebaseJobService you made in the last exercise with FirebaseJobDispatcher. You'll schedule it to run so that:
- It runs every 15 minutes with a flex-time window of 15 minutes
- It runs only if the phone is charging
- It runs forever after it's schedule, even if the user reboots the device
Exercise Code
Note: You should continue working off of the code you created in the last exercise. The code below is the exercise code from the start of this two part exercise.
SOLUTION:
- Schedule the `WaterReminderFirebaseJobService` with `FirebaseJobDispatcher`
- Remove the button and `testNotification` method